home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / owlbwcc.zip / BWMYBTN.CPP < prev    next >
C/C++ Source or Header  |  1992-01-26  |  3KB  |  81 lines

  1. /**********************************************************************/
  2. /*                  BWMYBTN.cpp by Bob Bourbonnais                    */
  3. /*              released to the public domain 1/26/92                 */
  4. /*          This program shows how to switch to different             */
  5. /*           routines based on the button pressed using               */
  6. /*           Dynamic Dispatched Virtual Tables, DDVT                  */
  7. /**********************************************************************/
  8. #include <owl.h>
  9. #include <dialog.h>
  10. #include "bwcc.h"                        // needed for BWCC
  11.  
  12. class TMyDialog : public TDialog
  13.   {
  14.   public:
  15.     TMyDialog(LPSTR lpDialogName)          // constructor calls
  16.       : TDialog(NULL,lpDialogName)         // base class constructor
  17.       {
  18.       BWCCGetVersion();    // activate Borland Windows Custom Controls
  19.       }
  20.    // The following Dynamic Dispatch Virtual Functions are linked
  21.     // to their associated subroutines
  22.  
  23.     virtual void HandleTest(RTMessage Msg)
  24.       = [ID_FIRST + 110];                    // The test button has ID of 110
  25.     virtual void HandleGo(RTMessage Msg)
  26.       = [ID_FIRST + 120];                    // The Go button has ID of 120
  27.  
  28.     virtual void DefChildProc(RTMessage Msg);  // Default handler for
  29.                            // Buttons not covered
  30.                            // by DDVT
  31.   };
  32.  
  33. void TMyDialog::HandleTest(RTMessage)
  34.   {
  35.   BWCCMessageBox(HWindow,"The Test Button was pressed",
  36.               "Button ID of 110 was pressed",MB_OK);
  37.   }
  38. void TMyDialog::HandleGo(RTMessage)
  39.   {
  40.   BWCCMessageBox(HWindow,"The Go button was pressed",
  41.              "Button ID of 120 was pressed",MB_OK);
  42.   }
  43.  
  44. void TMyDialog::DefChildProc(RTMessage Msg)
  45.   {
  46.   MessageBeep(0);
  47.   BWCCMessageBox(HWindow,"Not Implemented","Feature",MB_OK);
  48.   MessageBeep(0);
  49.   TDialog::DefChildProc(Msg);
  50.   }
  51.  
  52. class TDialog1App : public TApplication  // Application Class to contain
  53.   {                                      // the application
  54.   public:
  55.     TDialog1App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  56.         HANDLE hPrevInstance,            // base class constructor
  57.         LPSTR lpCmdLine, int nCmdShow)
  58.         :TApplication(lpName, hInstance,
  59.                   hPrevInstance,
  60.                   lpCmdLine, nCmdShow) {};
  61.  
  62.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  63.   };
  64.  
  65. void TDialog1App::InitMainWindow() // to initialize a dialog box
  66.   {                                // as the main window
  67.   MainWindow = new TMyDialog("MAINWINDOWDIALOG");
  68.   }
  69.  
  70. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  71.            HANDLE hPrevInstance,          // windows to this program
  72.            LPSTR lpCmdLine , int nCmdShow)
  73.   {
  74.   TDialog1App Dialog1("Dialog Tester",hInstance,  // create instance of
  75.                hPrevInstance,             // the dialog application
  76.                lpCmdLine,nCmdShow);
  77.   Dialog1.Run();                                  // run it
  78.   return (Dialog1.Status);                        // exit
  79.   }
  80. /**********************************************************************/
  81.